import 'package:flutter/material.dart';
import 'package:flutter_basic_learning/views/BottomNavigationBar/HotPage.dart';

import '../../utils/CommonWidget.dart';

class FlutterRoutePage extends StatefulWidget {
  const FlutterRoutePage({super.key});

  @override
  State<FlutterRoutePage> createState() => _FlutterRoutePageState();
}

//普通路由
Widget usualRoute(BuildContext context) {
  Widget body = ElevatedButton(
      onPressed: () {
        Navigator.of(context).push(
          MaterialPageRoute(
            builder: (context) {
              return const HotPage(
                  // arguments: {"title": "我是标题", "params": "我是参数"},
                  );
            },
          ),
        );
      },
      child: const Text('普通路由跳转'));
  body = Center(child: body);
  return body;
}

//命名路由
Widget namedRoute(BuildContext context) {
  Widget body = ElevatedButton(
    onPressed: () {
      Navigator.pushNamed(
        context,
        '/pageOne',
        arguments: {"title": "我是标题", "params": "我是参数"},
      );
    },
    child: const Text('命名路由'),
  );
  return body;
}

class _FlutterRoutePageState extends State<FlutterRoutePage> {
  @override
  Widget build(BuildContext context) {
    return commonScaffold(
      'Flutter 路由学习页面',
      [
        usualRoute(context),
        namedRoute(context),
      ],
    );
  }
}
